/**
 * Created by sangcixiang on 2019/1/8.
 */
import { Injectable } from '@angular/core';
@Injectable()

export class UserService{

  //用户基本信息
  public userId:number;                  //用户ID
  public userName:string;                //用户账号
  public access_token:string;            // token
  public registTime:string;              //注册时间
  public token_type:string;              //
  public trueName:string;                //真实姓名
  public cash:number = 0;                //钱包余额
  public isGetCash:boolean;              //是否拿到钱包余额
  public isLogin:boolean;                //是否登录
  public Email:string;                   //电子邮件
  public EmailValidateState:boolean;     //邮箱是否验证
  public Phone:string = null;            //手机号
  public PhoneValidateStatus:boolean;    //手机号是否验证
  public withdrawPwd:boolean;            //是否设置过取款密码
  public Birthday:string;                //生日
  public WeChat:string;                  //微信
  public QQ:string;                      //QQ
  public UserLevel:number;               //会员等级
  public UserLevelName:string;           //等级名称

  public platformsCash:any;              //各个平台余额
  public banks:any;                      //用户添加的银行卡
  public isDemo:boolean = false;         //是否试玩

  /**        存取款信息        **/
  public MaxDeposit:number;              //最大存款
  public MinDeposit:number;              //最小存款
  public AliPayMaxAmount:number;         //支付宝最大存款
  public AliPayMinAmount:number;         //支付宝最小存款
  public SingleMaxWithdraw:number;       //单次最大取款
  public SingleMinWithdraw:number;       //单次最小取款
  public ThirdPayDepositSingleMax:number;//第三方单次最大存款
  public ThirdPayDepositSingleMin:number;//第三方单次最小存款
  public WXMaxAmount:number;             //微信最大存款
  public WXMinAmount:number;             //微信最小存款

  constructor(){}

  public setUserInfo(obj){
    this.isLogin = true;
    this.userName = obj.UserName;
    this.trueName = obj.TrueName;
    this.userId = obj.Id;
    this.Email = obj.Email;
    this.Phone = obj.Phone;
    this.EmailValidateState = obj.EmailValidateState;
    this.PhoneValidateStatus = obj.PhoneValidateStatus;
    this.withdrawPwd = obj.HasWithdrawalPassword;
    this.Birthday = obj.Birthday;
    this.QQ = obj.QQ;
    this.WeChat = obj.WeChat;
    this.UserLevel = obj.UserLevel;
    this.UserLevelName = obj.UserLevelName;
    this.MaxDeposit = obj.MaxDeposit;
    this.MinDeposit = obj.MinDeposit;
    this.AliPayMaxAmount = obj.AliPayMaxAmount;
    this.AliPayMinAmount = obj.AliPayMinAmount;
    this.SingleMaxWithdraw = obj.SingleMaxWithdraw;
    this.SingleMinWithdraw = obj.SingleMinWithdraw;
    this.ThirdPayDepositSingleMax = obj.ThirdPayDepositSingleMax;
    this.ThirdPayDepositSingleMin = obj.ThirdPayDepositSingleMin;
    this.WXMaxAmount = obj.WXMinAmount;
    this.WXMinAmount = obj.WXMinAmount;
  }

  //自动登录
  // autoLogin(account){
    // console.log("登录中...");
    // let self = this;
    // let obj = {
    //   UserName:account.UserName,
    //   Password:account.Password,
    //   safety:0,
    //   comeFrom:self.nat.isIos?'iOS':'android'
    // };
    // this.user.login = true;
    // let url = this.http.baseUrl + "/api/Account/Login";
    // self.http.post(url,obj,function (res,err) {
    //   if(!err){
    //     console.log("登录成功!");
    //     // self.user.setUserInfo(res);
    //     self.user.login = false;
    //     self.user.isLogin = true;
    //     localStorage.setItem("authtoken",res.access_token);
    //     self.nat.storageSetValue("userInfo",JSON.stringify(res));
    //   }
    // });
  // }





  //获取用户其它信息
  // getUserOtherInfo(){
  //   this.getLoginUser();
  //
  // }
  // //获取当前用户钱包余额
  // getCash(){
  //   let url = "/api/User/GetUserCash";
  //   let self = this;
  //   this.http.get(url,{},function (res,err) {
  //     if(!err){
  //       console.log('当前余额：'+res);
  //       self.isGetCash = true;
  //       self.cash = res;
  //     }
  //   });
  // }





  // //获取当前用户是否设置取款密码
  // checkWithdrawPwd(){
  //   let url = "/api/User/CheckWithdrawPwd";
  //   let self = this;
  //   this.http.get(url,{},function (res,err) {
  //     if(!err){
  //       console.log('当前是否设置获取密码'+res);
  //       self.withdrawPwd = res;
  //     }
  //   });
  // }

  // getUserInfo(){
  //   let self = this;
  //   let url = "/api/User/GetByUserName";
  //   let map = {userName:this.userName};
  //   this.http.get(url,map,function (res,err) {
  //     if(!err){
  //       console.log("获取用户信息成功");
  //       self.Email = res.Email;
  //       self.Phone = res.Phone;
  //       self.EmailValidateState = res.EmailValidateState;
  //       self.PhoneValidateStatus = res.PhoneValidateStatus;
  //     }
  //   })
  // }


}
